//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.sinopec.siam.provisioning.filter;

import com.sinopec.siam.apache.log4j.Logger;
import com.sinopec.siam.provisioning.ProvisioningEventSubscriber;
import com.sinopec.siam.provisioning.handle.SimpleProvisioningEventListener;
import com.sinopec.siam.provisioning.listener.ProvisioningEventListener;
import com.sinopec.siam.provisioning.timer.ProvisioningEventSubscriberTimer;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class HrmListener implements ServletContextListener {

    private final Logger log = Logger.getLogger(HrmListener.class);

    public void contextInitialized(ServletContextEvent sce) {
        log.info("================>[Filter]准备开始接收消息");
        ProvisioningEventSubscriberTimer provisioningEventSubscriberTimer = ProvisioningEventSubscriberTimer.getInstance(new SimpleProvisioningEventListener());
        try {
            provisioningEventSubscriberTimer.start();
            log.info("================>[Filter]自动开始接收消息.");
        } catch (IllegalThreadStateException e) {
        }
    }

    public void contextDestroyed(ServletContextEvent sce) {
        try {
            ProvisioningEventSubscriber pes = ProvisioningEventSubscriber.getInstance();
            pes.stopReceiveMq();
            ProvisioningEventSubscriberTimer pest = ProvisioningEventSubscriberTimer.getInstance((ProvisioningEventListener) null);
            if (pest != null) {
                pest.interrupt();
            }
        } catch (Exception var4) {
            var4.printStackTrace();
        }

    }
}
